package com.ruoyi.procurement.design;

import com.ruoyi.common.exception.ServiceException;
import lombok.Getter;

@Getter
public enum ProcurementStateEnum {

    PENDING("0", "待审核"),
    APPROVED("1", "通过"),
    REJECTED("2", "驳回");

    private final String code;
    private final String desc;

    ProcurementStateEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ProcurementStateEnum fromCode(String code) {
        for (ProcurementStateEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new ServiceException("错误的状态类型：" + code);
    }

}
